raar.language.compiler
Class RAStringTool

java.lang.Object
  extended by raar.language.compiler.RAStringTool

public class RAStringTool
extends java.lang.Object

Useful string stuff.


Constructor Summary
RAStringTool()
           
 
Method Summary
static java.lang.String between(java.lang.String first, java.lang.String second, java.lang.String code)
          Returns the string in code between the two delimiters (first and second).
static java.lang.String betweenD(java.lang.String first, java.lang.String second, java.lang.String code)
          See between but delims must exist
static boolean contains(java.lang.String contains, java.lang.String s)
          Check containment.
static java.lang.String headOfString(java.lang.String delim, java.lang.String s)
          Returns the head of a string when tokenizing it on delim.
static java.lang.String headOfStringD(java.lang.String delim, java.lang.String s)
          See headofstring but delim must exist
static boolean isDelimiter(char ch)
          Request whether the character is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).
static boolean isDelimiter(java.lang.String s)
          Request whether the FIRST character in the given string is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).
static java.lang.String removeSpaces(java.lang.String in)
          Remove tabs and spaces from string.
static java.lang.String removeSpaces(java.lang.String in, java.lang.String spaces)
          Remove spaces as given from string.
static java.lang.String replaceSpaces(java.lang.String in, java.lang.String spaces, java.lang.String by)
          Replace spaces as given from string, by something else.
static java.lang.String revertString(java.lang.String s)
          Revert string... :)
static java.lang.String stringBetweenMatching(java.lang.String openMark, java.lang.String closeMark, java.lang.String s)
          Returns the string between the two marks, which are considered to be paired.
static java.lang.String tailOfString(java.lang.String delim, java.lang.String s)
          Returns the tail of a string when tokenizing it on delim.
static java.lang.String tailOfStringD(java.lang.String delim, java.lang.String s)
          See tailofstring but delim must exist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RAStringTool

public RAStringTool()
Method Detail

headOfString

public static java.lang.String headOfString(java.lang.String delim,
                                            java.lang.String s)
Returns the head of a string when tokenizing it on delim. So, headOfString(":=", "Voorbeeld:=5") returns "Voorbeeld". If the delim doesn't exist in the string, the complete string is returned.

Parameters:
delim - The delimiter.
s - The string to get the head of.

headOfStringD

public static java.lang.String headOfStringD(java.lang.String delim,
                                             java.lang.String s)
                                      throws java.lang.StringIndexOutOfBoundsException
See headofstring but delim must exist

Throws:
java.lang.StringIndexOutOfBoundsException

tailOfString

public static java.lang.String tailOfString(java.lang.String delim,
                                            java.lang.String s)
Returns the tail of a string when tokenizing it on delim. So, tailOfString(":=", "Voorbeeld:=5") returns "5". If the delim doesn't exist in the string, the empty string is returned.

Parameters:
delim - The delimiter.
s - The string to get the tail of.

tailOfStringD

public static java.lang.String tailOfStringD(java.lang.String delim,
                                             java.lang.String s)
                                      throws java.lang.StringIndexOutOfBoundsException
See tailofstring but delim must exist

Throws:
java.lang.StringIndexOutOfBoundsException

between

public static java.lang.String between(java.lang.String first,
                                       java.lang.String second,
                                       java.lang.String code)
Returns the string in code between the two delimiters (first and second). Essentially takes the head of the string and takes the tail of that.


betweenD

public static java.lang.String betweenD(java.lang.String first,
                                        java.lang.String second,
                                        java.lang.String code)
                                 throws java.lang.StringIndexOutOfBoundsException
See between but delims must exist

Throws:
java.lang.StringIndexOutOfBoundsException

stringBetweenMatching

public static java.lang.String stringBetweenMatching(java.lang.String openMark,
                                                     java.lang.String closeMark,
                                                     java.lang.String s)
Returns the string between the two marks, which are considered to be paired. That is, the corresponding closing mark will be sought for for the first encountered opening mark. Example: [this[is[a]test]] with [ and ] as marks will return this[is[a]test].


removeSpaces

public static java.lang.String removeSpaces(java.lang.String in)
Remove tabs and spaces from string.


removeSpaces

public static java.lang.String removeSpaces(java.lang.String in,
                                            java.lang.String spaces)
Remove spaces as given from string.


replaceSpaces

public static java.lang.String replaceSpaces(java.lang.String in,
                                             java.lang.String spaces,
                                             java.lang.String by)
Replace spaces as given from string, by something else.


revertString

public static java.lang.String revertString(java.lang.String s)
Revert string... :)


contains

public static boolean contains(java.lang.String contains,
                               java.lang.String s)
Check containment. Pre-Java 1.4...


isDelimiter

public static boolean isDelimiter(char ch)
Request whether the character is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).


isDelimiter

public static boolean isDelimiter(java.lang.String s)
Request whether the FIRST character in the given string is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).